#@weiXinLayout("客栈订单预览")

#define weiXinMain()
#@navBar("客栈订单预览","")
<div class="weui-form-preview">
    <div class="weui-form-preview__hd">
        <label class="weui-form-preview__label">付款金额</label>
        <em class="weui-form-preview__value">¥#(roomOrder.totalPrice()??'')</em>
    </div>
    <div class="weui-form-preview__bd">
        <div class="weui-form-preview__item">
            <label class="weui-form-preview__label">房间名称</label>
            <span class="weui-form-preview__value">#(roomOrder.room.name??'')</span>
        </div>
        <div class="weui-form-preview__item">
            <label class="weui-form-preview__label">预订时间</label>
            <span class="weui-form-preview__value">#(roomOrder.startTime()??'')至#(roomOrder. endTime()??'')</span>
        </div>
        <div class="weui-form-preview__item">
            <label class="weui-form-preview__label">证件类型</label>
            <span class="weui-form-preview__value">#(roomOrder.cardType()??'')</span>
        </div><div class="weui-form-preview__item">
            <label class="weui-form-preview__label">证件号码</label>
            <span class="weui-form-preview__value">#(roomOrder.card_no??'')</span>
        </div>
    </div>
    <div style="padding: 15px;">
        <a href="javascript:;" id="pay" class="weui-btn weui-btn_primary">确定支付当前订单</a>
    </div>
</div>
#end

#define weiXinCss()
#end

#define weiXinJs()
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script>
    $(document).ready(function() {
        /**
         * 支付相关
         */
        wx.config({
            debug: false,
            appId: '#(appId)',
            timestamp: '#(timestamp)',
            nonceStr: '#(nonceStr)',
            signature: '#(signature)',
            jsApiList: [  //需要使用的网页服务接口
                'checkJsApi',  //判断当前客户端版本是否支持指定JS接口
                //'onMenuShareTimeline', //分享给好友
                //'onMenuShareAppMessage', //分享到朋友圈
                //'onMenuShareQQ',  //分享到QQ
                //'onMenuShareWeibo', //分享到微博
                //'startRecord', 'stopRecord', 'playVoice', "uploadVoice",
                'chooseWXPay'
            ]
        });

        $('#pay').on("click", function () {
            var config = {
                "url": "#(contextPath)/weixin/pay/doRoomPay",
                "method": "POST",
                "data": {"id":"#(roomOrder.id??'')"},
                "successCallBack": function (resp) {
                    if (resp.result) {
                        WeixinJSBridge.invoke(
                            'getBrandWCPayRequest', {
                                "appId": resp.data.appId,     //公众号名称，由商户传入
                                "timeStamp": resp.data.timeStamp,         //时间戳，自1970年以来的秒数
                                "nonceStr": resp.data.nonceStr, //随机串
                                "package": resp.data.package,
                                "signType": "MD5",         //微信签名方式：
                                "paySign": resp.data.paySign //微信签名
                            },
                            function (res) {
                                if (res.err_msg == "get_brand_wcpay_request:ok") {
                                    window.location.href="#(contextPath)/weixin/order/payOrderSuccess?id=0"
                                }
                            }
                        );
                    } else {
                        $.alert(resp.msg);
                    }
                }
            };
            var ajax = new AjaxUtils(config);
            ajax.executeRequest();
        });
    });

</script>
#end